package com.xyz.graph.exception;

import com.xyz.graph.common.CommonResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@ControllerAdvice
public class ExceptionHandle {
    private final static Logger logger = LoggerFactory.getLogger(ExceptionHandle.class);

    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public CommonResult<Boolean> Handle(Exception e){
        logger.error("----系统异常--", e);
        return CommonResult.booleanError(-1, e.toString());
    }

    @ExceptionHandler(value = BuiltinSearchException.class)
    @ResponseBody
    public CommonResult<Boolean> GDataExceptionHandle(BuiltinSearchException e){
        logger.error("----程序捕获的异常--", e);
        //这里的返回Boolean?
        return CommonResult.booleanError(e.getCode(), e.getMessage());
    }

}
